// 1. 导入所需模块
import Vue from 'vue'
import VueRouter from 'vue-router'

import Detail from '@/components/Detail'
import Layout from '@/components/Layout'
import Login from '@/components/Login'
import Register from '@/components/Register'
import Article from '@/components/SecondLevel/Article'
import Collect from '@/components/SecondLevel/Collect'
import Like from '@/components/SecondLevel/Like'
import User from '@/components/SecondLevel/User'
// 2. 调用 Vue.use() 函数，将 VueRouter 安装为 Vue 的插件
Vue.use(VueRouter)

// 3. 配置路由规则
const routes = [
  { path: '/detail', component: Detail }, // 文章详情
  {
    path: '/layout', component: Layout, children: [
      { path: '/layout', redirect: '/layout/article' },
      { path: 'article', component: Article },
      { path: 'collect', component: Collect },
      { path: 'like', component: Like },
      { path: 'user', component: User },
    ]
  }, //首页
  { path: '/login', component: Login },  //登录页
  { path: '/register', component: Register },  //注册页
]

// 4. 创建路由的实例对象
const router = new VueRouter({
  /*路由的配置*/
  routes
})

// 5. 导出路由的实例对象
export default router